<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.value" clearable placeholder="输入名称搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <!-- 新增 -->
    <div style="display: inline-block;margin: 0px 2px;">
      <el-button
        v-if="checkPermission(['admin','dict_all','dict_create'])"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="$refs.form.dialog = true;addDict()">新增</el-button>
      <eForm ref="form" :dict-id="dictId" :is-add="true" @getDictDetail="toQuery"/>
    </div>
  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import eForm from './form/dictDetail'
export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    },
    dictId: {
      type: String,
      required: true
    },
    currentData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      downloadLoading: false
    }
  },
  methods: {
    checkPermission,
    toQuery() {
      console.log(this.query)
      this.$emit('getDictDetail')
    },
    addDict() {
      this.$refs.form.currentData = this.currentData
      this.$refs.form.getDictDetail()
    }
  }
}
</script>
